#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
+#include <locale.h>
#include <X11/extensions/Xfixes.h>
#include <canberra.h>
+#include <canberra-gtk.h>
#include <clutter/glx/clutter-glx.h>
#include <clutter/x11/clutter-x11.h>
#include <gdk/gdkx.h>
global->input_mode = SHELL_STAGE_INPUT_MODE_NORMAL;
- ca_context_create (&global->sound_context);
- ca_context_change_props (global->sound_context, CA_PROP_APPLICATION_NAME, PACKAGE_NAME, CA_PROP_APPLICATION_ID, "org.gnome.Shell", NULL);
+ global->sound_context = ca_gtk_context_get ();
+ ca_context_change_props (global->sound_context,
+ CA_PROP_APPLICATION_NAME, "GNOME Shell",
+ CA_PROP_APPLICATION_ID, "org.gnome.Shell",
+ CA_PROP_APPLICATION_ICON_NAME, "start-here",
+ CA_PROP_APPLICATION_LANGUAGE, setlocale (LC_MESSAGES, NULL),
+ NULL);
ca_context_open (global->sound_context);
if (!shell_js)
schedule_leisure_functions (global);
}
+static void
+build_ca_proplist_for_event (ca_proplist *props,
+ const char *event_id,
+ const char *event_description,
+ ClutterEvent *for_event)
+{
+ ca_proplist_sets (props, CA_PROP_EVENT_ID, event_id);
+ ca_proplist_sets (props, CA_PROP_EVENT_DESCRIPTION, event_description);
+ ca_proplist_sets (props, CA_PROP_CANBERRA_CACHE_CONTROL, "volatile");
+
+ if (for_event)
+ {
+ if (clutter_event_type (for_event) != CLUTTER_KEY_PRESS &&
+ clutter_event_type (for_event) != CLUTTER_KEY_RELEASE)
+ {
+ ClutterPoint point;
+
+ clutter_event_get_position (for_event, &point);
+
+ ca_proplist_setf (props, CA_PROP_EVENT_MOUSE_X, "%d", (int)point.x);
+ ca_proplist_setf (props, CA_PROP_EVENT_MOUSE_Y, "%d", (int)point.y);
+ }
+
+ if (clutter_event_type (for_event) == CLUTTER_BUTTON_PRESS ||
+ clutter_event_type (for_event) == CLUTTER_BUTTON_RELEASE)
+ {
+ gint button;
+
+ button = clutter_event_get_button (for_event);
+ ca_proplist_setf (props, CA_PROP_EVENT_MOUSE_BUTTON, "%d", button);
+ }
+ }
+}
+
/**
* shell_global_play_theme_sound:
* @global: the #ShellGlobal
* @id: an id, used to cancel later (0 if not needed)
* @name: the sound name
+ * @for_event: (allow-none): a #ClutterEvent in response to which the sound is played
*
* Plays a simple sound picked according to Freedesktop sound theme.
* Really just a workaround for libcanberra not being introspected.
*/
void
-shell_global_play_theme_sound (ShellGlobal *global,
- guint id,
- const char *name)
+shell_global_play_theme_sound (ShellGlobal *global,
+ guint id,
+ const char *name,
+ const char *description,
+ ClutterEvent *for_event)
{
- ca_context_play (global->sound_context, id, CA_PROP_EVENT_ID, name, NULL);
+ ca_proplist *props;
+
+ ca_proplist_create (&props);
+ build_ca_proplist_for_event (props, name, description, for_event);
+
+ ca_context_play_full (global->sound_context, id, props, NULL, NULL);
+
+ ca_proplist_destroy (props);
+}
+
+/**
+ * shell_global_play_theme_sound_full:
+ * @global: the #ShellGlobal
+ * @id: an id, used to cancel later (0 if not needed)
+ * @name: the sound name
+ * @description: the localized description of the event that triggered this alert
+ * @for_event: (allow-none): a #ClutterEvent in response to which the sound is played
+ * @application_id: application on behalf of which the sound is played
+ * @application_name:
+ *
+ * Plays a simple sound picked according to Freedesktop sound theme.
+ * Really just a workaround for libcanberra not being introspected.
+ */
+void
+shell_global_play_theme_sound_full (ShellGlobal *global,
+ guint id,
+ const char *name,
+ const char *description,
+ ClutterEvent *for_event,
+ const char *application_id,
+ const char *application_name)
+{
+ ca_proplist *props;
+
+ ca_proplist_create (&props);
+ build_ca_proplist_for_event (props, name, description, for_event);
+ ca_proplist_sets (props, CA_PROP_APPLICATION_ID, application_id);
+ ca_proplist_sets (props, CA_PROP_APPLICATION_NAME, application_name);
+
+ ca_context_play_full (global->sound_context, id, props, NULL, NULL);
+
+ ca_proplist_destroy (props);
}
/**